Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create custom logs cleanup function #3610

Merged
merged 11 commits into from
Mar 4, 2024
Merged

fix: create custom logs cleanup function #3610

merged 11 commits into from
Mar 4, 2024

Conversation

robertsLando
Copy link
Member

Ref: #3609

api/lib/logger.ts Fixed Show fixed Hide fixed
api/lib/logger.ts Outdated Show resolved Hide resolved
Copy link

@Apollon77 Apollon77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just the one comment in the regex ... most likely a no reality issue, but edge case

// clean up old log files based on maxFiles and maxSize

const filePathRegExp = new RegExp(
path.basename(settings.filename).replace(/%DATE%/g, '([^.]+)'),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

settings.filename contains ".log", right? So the "." should be escaped?

Copy link
Member Author

@robertsLando robertsLando Feb 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Apollon77 in that case [^.]+ means: take everything that is not a dot. So it will stop just before the .log. This of course could be broken in case %DATE% contains a dot but 🤷🏼‍♂️

Example here: https://regex101.com/r/kKW5ox/1

Copy link
Member Author

@robertsLando robertsLando Feb 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a new version of the regex to make it stronger, it will work for every date format, it just takes everything between the %DATE% prefix/suffix:

https://regex101.com/r/7LG6L6/1

api/lib/logger.ts Fixed Show fixed Hide fixed
api/lib/logger.ts Fixed Show fixed Hide fixed
api/lib/logger.ts Fixed Show fixed Hide fixed
@coveralls
Copy link

Pull Request Test Coverage Report for Build 8007979295

Details

  • -26 of 162 (83.95%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.6%) to 22.559%

Changes Missing Coverage Covered Lines Changed/Added Lines %
api/lib/logger.ts 136 162 83.95%
Totals Coverage Status
Change from base Build 8007839126: 0.6%
Covered Lines: 3896
Relevant Lines: 18341

💛 - Coveralls

@robertsLando robertsLando merged commit 64f32f0 into master Mar 4, 2024
9 checks passed
@robertsLando robertsLando deleted the cleanup-logs branch March 4, 2024 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants